<?php  
/*
** etc:  路由类
** author: deepe.xiao
** update: 2018-10-10
*/

use app\controllers;
class Route{
	
	public function __construct(){
	}
	public function autoLoadClass($class){
		$spm = isset( $_REQUEST['spm'] ) ? $_REQUEST['spm'] : "";
		$version = reviewVersionCode( $spm );
		//
		$version = explode("_",$version);
		$version = $version[0]."_".$version[1];
		//转成小写,转为首字母大写
		$class = ucfirst(strtolower($class));
		$targetName = FCPATH."app/controllers/".config_item('pj_name')."_".$version."/".$class.".php";

		if( file_exists( $targetName ) ){
			include_once $targetName;
			$class = ucfirst($class);
			$class = 'app\\controllers\\'.config_item('pj_name')."_".$version."\\".$class;
			$obj = new $class();	
		}else{
			view_log( "deepe Framework Error","Sorry, not action exists" );
			exit;
		}
		return $obj;
	}	
	
	public function autoLoadAdmin($class){
		$class = strtolower($class);
		if( strlen($class) != 0 ){
			include_once( FCPATH."/app/controllers/admin/".$class.".php" );
			$class = "C".$class;
			$class = 'app\\controllers\\admin\\'.$class;
			$obj = new $class;	
		}
		return $obj;
	}	
}
?>